package com.cictec.middleware.core.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.cictec.middleware.commons.utils.DateUtils;
import com.cictec.middleware.gps.engine.TimingPoint;

public class TimingPointTM implements Serializable {

	private static final long serialVersionUID = -7332176972225536624L;
	private Date time;
	private List<String> attributes = new ArrayList<String>();

	public TimingPointTM() {
	}

	public TimingPointTM(TimingPoint timingPoint) {
		time = timingPoint.getTime();

		attributes.add(timingPoint.getDevCode());
		attributes.add(timingPoint.getGatherTime());
		attributes.add(timingPoint.getUploadTime());
		attributes.add(timingPoint.getDevLineId());
		attributes.add(timingPoint.getLatitudeIndicator());
		attributes.add(timingPoint.getLatitude());
		attributes.add(timingPoint.getLongitudeIndicator());
		attributes.add(timingPoint.getLongitude());
		attributes.add(timingPoint.getCounrse());
		attributes.add(timingPoint.getSpeed());

		attributes.add(timingPoint.getLineUuid());
		attributes.add(timingPoint.getLineName());
		attributes.add(timingPoint.getBusUuid());
		attributes.add(timingPoint.getBusNumber());
	}

	public TimingPoint parseTimingPoint() {

		TimingPoint timingPoint = new TimingPoint();
		timingPoint.setDevCode(attributes.get(0));

		timingPoint.setTime(DateUtils.parseDateTimes(attributes.get(1)));
		timingPoint.setGatherTime(attributes.get(1));

		timingPoint.setUploadTime(attributes.get(2));
		timingPoint.setDevLineId(attributes.get(3));
		timingPoint.setLatitudeIndicator(attributes.get(4));
		timingPoint.setLatitude(attributes.get(5));
		timingPoint.setLongitudeIndicator(attributes.get(6));
		timingPoint.setLongitude(attributes.get(7));
		timingPoint.setCounrse(attributes.get(8));
		timingPoint.setSpeed(attributes.get(9));

		timingPoint.setLineUuid(attributes.get(10));
		timingPoint.setLineName(attributes.get(11));
		timingPoint.setBusUuid(attributes.get(12));
		timingPoint.setBusNumber(attributes.get(13));
		return timingPoint;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public List<String> getAttributes() {
		return attributes;
	}

	public void setAttributes(List<String> attributes) {
		this.attributes = attributes;
	}

}
